package day3

import Utils.SparkUtils
import org.apache.spark.SparkContext
import org.apache.spark.rdd.RDD

object Test1 {
  def main(args: Array[String]): Unit = {
    val sc: SparkContext = SparkUtils.getSparkContext(4, "bitter")

    val rdd1 = sc.textFile("hdfs://hadoop10:9000/bigbig.log")

    rdd1.flatMap(v => v.split(",")).map(v => (v,1)).groupByKey().map(v => (v._1,v._2.size)).saveAsTextFile("hdfs://hadoop10:9000/out8")

    rdd1.flatMap(v => v.split(",")).map(v => (v,1)).reduceByKey((v1,v2) => v1+v2).saveAsTextFile("hdfs://hadoop10:9000/out7")

    sc.stop()
  }
}
